dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, event->area.width, event->area.height);
- if (pixbuf->art_pixbuf->has_alpha || overall_alpha != 255)
- gdk_pixbuf_composite_color (pixbuf, dest,
- 0, 0, event->area.width, event->area.height,
- -event->area.x, -event->area.y,
- (double) widget->allocation.width / pixbuf->art_pixbuf->width,
- (double) widget->allocation.height / pixbuf->art_pixbuf->height,
- filter_level, overall_alpha,
- event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
- else
- gdk_pixbuf_scale (pixbuf, dest,
- 0, 0, event->area.width, event->area.height,
- -event->area.x, -event->area.y,
- (double) widget->allocation.width / pixbuf->art_pixbuf->width,
- (double) widget->allocation.height / pixbuf->art_pixbuf->height,
- filter_level);
-
+ gdk_pixbuf_composite_color (pixbuf, dest,
+ 0, 0, event->area.width, event->area.height,
+ -event->area.x, -event->area.y,
+ (double) widget->allocation.width / pixbuf->art_pixbuf->width,
+ (double) widget->allocation.height / pixbuf->art_pixbuf->height,
+ filter_level, overall_alpha,
+ event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
0, 0, event->area.x, event->area.y,
tmpl/gnome-canvas-pixbuf.sgml \
tmpl/refcounting.sgml \
tmpl/rendering.sgml \
+ tmpl/scaling.sgml \
tmpl/util.sgml
gdk_pixbuf_docdir = $(HTML_DIR)
-(cd $(srcdir) \
&& env CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) \
gtkdoc-scanobj --module=$(DOC_MODULE) \
- && gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) )
+ && gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="pixops.h pixops-internal.h" )
templates: scan
cd $(srcdir) && gtkdoc-mktmpl --module=$(DOC_MODULE)
<USER_FUNCTION>
<NAME>ModuleUpdatedNotifyFunc</NAME>
<RETURNS>void </RETURNS>
-GdkPixbuf *pixbuf, gpointer user_data,
+GdkPixbuf *pixbuf,
guint x, guint y,
- guint width, guint height
+ guint width, guint height,
+ gpointer user_data
+</USER_FUNCTION>
+<USER_FUNCTION>
+<NAME>ModuleFrameDoneNotifyFunc</NAME>
+<RETURNS>void </RETURNS>
+GdkPixbuf *pixbuf,
+ gint frame,
+ gpointer user_data
+</USER_FUNCTION>
+<USER_FUNCTION>
+<NAME>ModuleAnimationDoneNotifyFunc</NAME>
+<RETURNS>void </RETURNS>
+GdkPixbuf *pixbuf,
+ gpointer user_data
</USER_FUNCTION>
<STRUCT>
<NAME>GdkPixbufModule</NAME>
gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func,
ModuleUpdatedNotifyFunc update_func,
+ ModuleFrameDoneNotifyFunc frame_done_func,
+ ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data);
void (* stop_load) (gpointer context);
gboolean (* load_increment) (gpointer context, const guchar *buf, guint size);
GdkPixbuf *dest,GdkDrawable *src, GdkColormap *cmap,int src_x, int src_y,int dest_x, int dest_y,int width, int height
</FUNCTION>
<FUNCTION>
+<NAME>gdk_pixbuf_scale</NAME>
+<RETURNS>void </RETURNS>
+GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level
+</FUNCTION>
+<FUNCTION>
+<NAME>gdk_pixbuf_composite</NAME>
+<RETURNS>void </RETURNS>
+GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level,int overall_alpha
+</FUNCTION>
+<FUNCTION>
+<NAME>gdk_pixbuf_composite_color</NAME>
+<RETURNS>void </RETURNS>
+GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level,int overall_alpha,int check_x,int check_y,int check_size,art_u32 color1,art_u32 color2
+</FUNCTION>
+<FUNCTION>
+<NAME>gdk_pixbuf_scale_simple</NAME>
+<RETURNS>GdkPixbuf *</RETURNS>
+GdkPixbuf *src,int dest_width,int dest_height,ArtFilterLevel filter_level
+</FUNCTION>
+<FUNCTION>
+<NAME>gdk_pixbuf_composite_color_simple</NAME>
+<RETURNS>GdkPixbuf *</RETURNS>
+GdkPixbuf *src,int dest_width,int dest_height,ArtFilterLevel filter_level,int overall_alpha,int check_size,art_u32 color1,art_u32 color2
+</FUNCTION>
+<FUNCTION>
<NAME>gdk_pixbuf_animation_new_from_file</NAME>
<RETURNS>GdkPixbufAnimation *</RETURNS>
const char *filename
gdk_pixbuf_animation_unref
</SECTION>
+<SECTION>
+<FILE>scaling</FILE>
+gdk_pixbuf_scale
+gdk_pixbuf_composite
+gdk_pixbuf_composite_color
+gdk_pixbuf_scale_simple
+gdk_pixbuf_composite_color_simple
+</SECTION>
+
<SECTION>
<FILE>gdk-pixbuf-loader</FILE>
GDK_PIXBUF_LOADER
</ARG>
<ARG>
-<NAME>GnomeCanvasPixbuf::width_in_pixels</NAME>
+<NAME>GnomeCanvasPixbuf::width_pixels</NAME>
<TYPE>gboolean</TYPE>
<FLAGS>rw</FLAGS>
</ARG>
</ARG>
<ARG>
-<NAME>GnomeCanvasPixbuf::height_in_pixels</NAME>
+<NAME>GnomeCanvasPixbuf::height_pixels</NAME>
<TYPE>gboolean</TYPE>
<FLAGS>rw</FLAGS>
</ARG>
</ARG>
<ARG>
-<NAME>GnomeCanvasPixbuf::x_in_pixels</NAME>
+<NAME>GnomeCanvasPixbuf::x_pixels</NAME>
<TYPE>gboolean</TYPE>
<FLAGS>rw</FLAGS>
</ARG>
</ARG>
<ARG>
-<NAME>GnomeCanvasPixbuf::y_in_pixels</NAME>
+<NAME>GnomeCanvasPixbuf::y_pixels</NAME>
<TYPE>gboolean</TYPE>
<FLAGS>rw</FLAGS>
</ARG>
<!entity gdk-pixbuf-file-loading SYSTEM "sgml/file-loading.sgml">
<!entity gdk-pixbuf-creating SYSTEM "sgml/creating.sgml">
<!entity gdk-pixbuf-rendering SYSTEM "sgml/rendering.sgml">
+<!entity gdk-pixbuf-scaling SYSTEM "sgml/scaling.sgml">
<!entity gdk-pixbuf-from-drawables SYSTEM "sgml/from-drawables.sgml">
<!entity gdk-pixbuf-util SYSTEM "sgml/util.sgml">
<!entity gdk-pixbuf-animation SYSTEM "sgml/animation.sgml">
&gdk-pixbuf-file-loading;
&gdk-pixbuf-creating;
&gdk-pixbuf-rendering;
+ &gdk-pixbuf-scaling;
&gdk-pixbuf-from-drawables;
&gdk-pixbuf-util;
&gdk-pixbuf-animation;
about the frame's overlay mode and duration.
</para>
-
<!-- ##### SECTION See_Also ##### -->
<para>
#GdkPixbufLoader
</para>
-
<!-- ##### ENUM GdkPixbufFrameAction ##### -->
<para>
Each animation frame can have several things happen to it when the
</para>
-@animation:
-
-
-<!--
+@animation: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
+
+
@dest_y:
@width:
@height:
-@Returns:
-
-<!--
+@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
+<!-- ##### ARG GnomeCanvasPixbuf:width_in_pixels ##### -->
+ <para>
+ If this argument is %TRUE, then the width of the pixbuf will be
+ considered to be in pixels, that is, it will not be visually
+ scaled even if the item's affine transformation changes. If this
+ is %FALSE, then the width of the pixbuf will be considered to be
+ in canvas units, and so will be scaled normally by affine
+ transformations. The default is %FALSE.
+ </para>
+
+
<!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:See_Also ##### -->
<para>
+<!-- ##### ARG GnomeCanvasPixbuf:height_in_pixels ##### -->
+ <para>
+ Works in the same way as the <link
+ linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
+ argument. The default is %FALSE.
+ </para>
+
+
<!-- ##### STRUCT GdkPixbufModule ##### -->
<para>
@stop_load:
@load_increment:
+<!-- ##### ARG GnomeCanvasPixbuf:y_in_pixels ##### -->
+ <para>
+ Works in the same way as the <link
+ linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>
+ argument. The default is %FALSE.
+ </para>
+
+<!--
+Local variables:
+mode: sgml
+sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
+End:
+-->
+
+
<!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:Long_Description ##### -->
<para>
@size:
@Returns:
+<!-- ##### ARG GnomeCanvasPixbuf:x_in_pixels ##### -->
+ <para>
+ If this argument is %TRUE, the pixbuf's translation with respect
+ to its logical origin in item-relative coordinates will be in
+ pixels, that is, the visible offset will not change even if the
+ item's affine transformation changes. If it is %FALSE, the
+ pixbuf's translation will be taken to be in canvas units, and thus
+ will change along with the item's affine transformation.
+ </para>
+
+
used instead. This argument is %FALSE by default.
</para>
-<!-- ##### ARG GnomeCanvasPixbuf:width_in_pixels ##### -->
- <para>
- If this argument is %TRUE, then the width of the pixbuf will be
- considered to be in pixels, that is, it will not be visually
- scaled even if the item's affine transformation changes. If this
- is %FALSE, then the width of the pixbuf will be considered to be
- in canvas units, and so will be scaled normally by affine
- transformations. The default is %FALSE.
- </para>
+<!-- ##### ARG GnomeCanvasPixbuf:width_pixels ##### -->
+<para>
+
+</para>
<!-- ##### ARG GnomeCanvasPixbuf:height ##### -->
<para>
The default is %FALSE.
</para>
-<!-- ##### ARG GnomeCanvasPixbuf:height_in_pixels ##### -->
- <para>
- Works in the same way as the <link
- linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
- argument. The default is %FALSE.
- </para>
+<!-- ##### ARG GnomeCanvasPixbuf:height_pixels ##### -->
+<para>
+
+</para>
<!-- ##### ARG GnomeCanvasPixbuf:x ##### -->
<para>
coordinates.
</para>
-<!-- ##### ARG GnomeCanvasPixbuf:x_in_pixels ##### -->
- <para>
- If this argument is %TRUE, the pixbuf's translation with respect
- to its logical origin in item-relative coordinates will be in
- pixels, that is, the visible offset will not change even if the
- item's affine transformation changes. If it is %FALSE, the
- pixbuf's translation will be taken to be in canvas units, and thus
- will change along with the item's affine transformation.
- </para>
+<!-- ##### ARG GnomeCanvasPixbuf:x_pixels ##### -->
+<para>
+
+</para>
<!-- ##### ARG GnomeCanvasPixbuf:y ##### -->
<para>
default is %FALSE.
</para>
-<!-- ##### ARG GnomeCanvasPixbuf:y_in_pixels ##### -->
- <para>
- Works in the same way as the <link
- linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>
- argument. The default is %FALSE.
- </para>
+<!-- ##### ARG GnomeCanvasPixbuf:y_pixels ##### -->
+<para>
-<!--
-Local variables:
-mode: sgml
-sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
-End:
--->
+</para>
--- /dev/null
+<!-- ##### SECTION Title ##### -->
+Scaling
+
+<!-- ##### SECTION Short_Description ##### -->
+Scaling pixbufs and scaling and compositing pixbufs
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+gdk-pixbuf contains functions to scale pixbufs, to scale pixbufs and
+composite against an existing image, and to scale pixbufs and
+composite against a solid color or checkerboard. (Compositing a
+checkerboard is a common way to show an image with an alpha-channel in
+image-viewing and editing software.)
+</para>
+<para>
+Since the full-featured functions (gdk_pixbuf_scale(),
+gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are
+rather complex to use and have many arguments, two simple
+convenience functions are provided, gdk_pixbuf_scale_simple()
+and gdk_pixbuf_composite_color_simple() which create a
+new pixbuf of a given size, scale an original image to fit,
+and then return the new pixmap.
+</para>
+
+<para>
+The following example demonstrates handling an expose event by
+rendering the appropriate area of a source image (which is scaled to
+fit the widget) onto the widget's window. The source image is
+rendered against a checkerboard, which provides a visual
+representation of the alpha channel if the image has one. If the image
+doesn't have an alpha channel, calling gdk_pixbuf_composite_color()
+function has exactly the same effect as calling gdk_pixbuf_scale().
+</para>
+
+<programlisting>
+gboolean
+expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
+{
+ GdkPixbuf *dest;
+
+ gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
+
+ dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, event->area.width, event->area.height);
+
+ gdk_pixbuf_composite_color (pixbuf, dest,
+ 0, 0, event->area.width, event->area.height,
+ -event->area.x, -event->area.y,
+ (double) widget->allocation.width / pixbuf->art_pixbuf->width,
+ (double) widget->allocation.height / pixbuf->art_pixbuf->height,
+ filter_level, 255,
+ event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
+
+ gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
+ 0, 0, event->area.x, event->area.y,
+ event->area.width, event->area.height,
+ GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
+
+ gdk_pixbuf_unref (dest);
+
+ return TRUE;
+}
+</programlisting>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### FUNCTION gdk_pixbuf_scale ##### -->
+<para>
+
+</para>
+
+@src:
+@dest:
+@dest_x:
+@dest_y:
+@dest_width:
+@dest_height:
+@offset_x:
+@offset_y:
+@scale_x:
+@scale_y:
+@filter_level:
+
+
+<!-- ##### FUNCTION gdk_pixbuf_composite ##### -->
+<para>
+
+</para>
+
+@src:
+@dest:
+@dest_x:
+@dest_y:
+@dest_width:
+@dest_height:
+@offset_x:
+@offset_y:
+@scale_x:
+@scale_y:
+@filter_level:
+@overall_alpha:
+
+
+<!-- ##### FUNCTION gdk_pixbuf_composite_color ##### -->
+<para>
+
+</para>
+
+@src:
+@dest:
+@dest_x:
+@dest_y:
+@dest_width:
+@dest_height:
+@offset_x:
+@offset_y:
+@scale_x:
+@scale_y:
+@filter_level:
+@overall_alpha:
+@check_x:
+@check_y:
+@check_size:
+@color1:
+@color2:
+
+
+<!-- ##### FUNCTION gdk_pixbuf_scale_simple ##### -->
+<para>
+
+</para>
+
+@src:
+@dest_width:
+@dest_height:
+@filter_level:
+@Returns:
+
+
+<!-- ##### FUNCTION gdk_pixbuf_composite_color_simple ##### -->
+<para>
+
+</para>
+
+@src:
+@dest_width:
+@dest_height:
+@filter_level:
+@overall_alpha:
+@check_size:
+@color1:
+@color2:
+@Returns:
+
+<!--
+Local variables:
+mode: sgml
+sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
+End:
+-->
\ No newline at end of file
@r:
@g:
@b:
-@Returns:
-<!--
+@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
+2000-01-05 Owen Taylor <otaylor@redhat.com>
+
+ * doc/Makefile.am doc/gdk-pixbuf-sections.txt
+ doc/gdk-pixbuf.sgml doc/tmpl/scaling.sgml:
+ Added scaling functions into gtk-doc framework.
+
+ * gdk-pixbuf/gdk-pixbuf-scale.c: Documentation fixes.
+
+ * gdk-pixbuf/testpixbuf-scale.c (expose_cb): Simplify a bit.
+
+ * gdk-pixbuf/pixops/pixops.c (pixops_composite_color): Return
+ immediately if scale_x or scale_y is 0.
+
2000-01-05 Owen Taylor <otaylor@redhat.com>
* gdk-pixbuf/pixops/timescale.c: quick fix for initializing
* gdk_pixbuf_scale:
* @src: a #GdkPixbuf
* @dest: the #GdkPixbuf into which to render the results
- * @dest_x:
- * @dest_y:
- * @dest_width:
- * @dest_height:
+ * @dest_x: the left coordinate for region to render
+ * @dest_y: the top coordinate for region to render
+ * @dest_width: the width of the region to render
+ * @dest_height: the height of the region to render
* @offset_x: the offset in the X direction (currently rounded to an integer)
* @offset_y: the offset in the Y direction (currently rounded to an integer)
* @scale_x: the scale factor in the X direction
* gdk_pixbuf_composite:
* @src: a #GdkPixbuf
* @dest: the #GdkPixbuf into which to render the results
- * @dest_x:
- * @dest_y:
- * @dest_width:
- * @dest_height:
+ * @dest_x: the left coordinate for region to render
+ * @dest_y: the top coordinate for region to render
+ * @dest_width: the width of the region to render
+ * @dest_height: the height of the region to render
* @offset_x: the offset in the X direction (currently rounded to an integer)
* @offset_y: the offset in the Y direction (currently rounded to an integer)
* @scale_x: the scale factor in the X direction
* gdk_pixbuf_composite_color:
* @src: a #GdkPixbuf
* @dest: the #GdkPixbuf into which to render the results
- * @dest_x:
- * @dest_y:
- * @dest_width:
- * @dest_height:
+ * @dest_x: the left coordinate for region to render
+ * @dest_y: the top coordinate for region to render
+ * @dest_width: the width of the region to render
+ * @dest_height: the height of the region to render
* @offset_x: the offset in the X direction (currently rounded to an integer)
* @offset_y: the offset in the Y direction (currently rounded to an integer)
* @scale_x: the scale factor in the X direction
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
g_return_if_fail (!(src_channels == 3 && src_has_alpha));
+ if (scale_x == 0 || scale_y == 0)
+ return;
+
if (!src_has_alpha && overall_alpha == 255)
pixops_scale (dest_buf, render_x0, render_y0, render_x1, render_y1,
dest_rowstride, dest_channels, dest_has_alpha,
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
g_return_if_fail (!(src_channels == 3 && src_has_alpha));
+ if (scale_x == 0 || scale_y == 0)
+ return;
+
if (!src_has_alpha && overall_alpha == 255)
pixops_scale (dest_buf, render_x0, render_y0, render_x1, render_y1,
dest_rowstride, dest_channels, dest_has_alpha,
g_return_if_fail (!(src_channels == 3 && src_has_alpha));
g_return_if_fail (!(src_has_alpha && !dest_has_alpha));
+ if (scale_x == 0 || scale_y == 0)
+ return;
+
switch (filter_level)
{
case ART_FILTER_NEAREST: